<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>教师后台-不学也通</title>
    <link rel="shortcut icon" href="../康笑长结业课.jpg" type="image/x-icon">
    <style>
        .container {
            min-height: 100vh;
        }

        .container .nav {
            height: 100%;
            background-color: #fff;
        }

        .link-secondary{
            text-decoration: none;
        }
        .link-secondary:hover{
            color: #0d6efd !important;
        }
    </style>
</head>

<body>
    <!-- container是bootstrap的居中窄的显示方案 -->
    <div class="container bg-body">
        <div class="row">
            <div class="col-md-2 leftmenu" id="leftmenu">
                
            </div>
            <div class="col-md-9 kc ms-3">
                <div class="row mt-3 pd-3 border-bottom border-secondary">
                    <div class="col-md-2">创建课程</div>
                    <div class="col-md-1 offset-md-8">
                        <a class="nav-link link-success" href="./index.html">返回</a>
                    </div>
            </div>
            <div class="row mt-3">
                <form>
                   <div class="mb-3 row">
                       <label for="course-number" class="col-sm-2 col-form-label">课程编号</label>
                       <div class="col-sm-10">
                         <input type="text" class="form-control" id="course-number">
                       </div>
                     </div>
                     <div class="mb-3 row">
                       <label for="course-name" class="col-sm-2 col-form-label">课程名称</label>
                       <div class="col-sm-10">
                         <input type="text" class="form-control" id="course-name">
                       </div>
                     </div>
                     <div class="mb-3 row">
                        <label for="course-name" class="col-sm-2 col-form-label">图片</label>
                        <div class="col-sm-10">
                          <input type="text" class="form-control" id="picture">
                        </div>
                      </div>
                     <div class="mb-3 row">
                       <label for="course-department" class="col-sm-2 col-form-label">院系:</label>
                       <div class="col-sm-10">
                           <select class="form-select" aria-label="Default select example">
                               <option selected>-- 请选择院系 --</option>
                               <option value="1">计算机科学与应用</option>
                               <option value="2">教育系</option>
                               <option value="3">中文系</option>
                               <option value="4">数学系</option>
                               <option value="5">美术系</option>
                               <option value="6">音乐系</option>
                               <option value="7">体育系</option>
                               <option value="8">旅游与酒店管理系</option>
                               <option value="9">机电系</option>
                               <option value="10">幼儿师范部</option>
                             </select>
                       </div>
                     </div>
                     <div class="mb-3 row">
                       <label for="course-teacher" class="col-sm-2 col-form-label">教师</label>
                       <div class="col-sm-10">
                         <input type="text" class="form-control" id="course-teacher">
                       </div>
                     </div>
                     <div class="mb-3 row">
                       <div class="col-sm-12">
                           <button type="submit" class="btn btn-outline-primary">提交</button>
                       </div>
                     </div>
                </form>
           </div>
       </div>
   </div>
</div>
    <script type="module" src="../js/main.js"></script>
    <script src="../js/jquery.min.js"></script>
    <script src="../js/common.js"></script>
    <script>
        $(document).ready(function(){
            // 当用户点击class是nav-tab的标签给给该标签(添加之前删除所有active类)添加active类
            $(".nav-tab").click(function(e){
            // 删除nav-tab所有的active类
            $(".nav-tab").removeClass("active");
            // 给点击的标签添加active
            $(this).addclass("active");
        })
        $(".btn-outline-primary").click(function(){
                // 获取提交数据
                // 方法一 获取全部
                // console.log($("#studentFrom").serializeArray()); 获取form表单中所有要提交的信息
                // console.log($("#studentFrom").serializeArray());

                // 方式二 一个一个获取
                let teacher_id= $("#course-number").val();
                let course_name = $("#course-name").val();
                let teacher_name= $("#course-teacher").val();
                let course_url= $("#picture").val();
                $.post("https://unicloud.codecore.cn/ms/courseCreate",{
                    teacher_id:teacher_id,
                    course_name:course_name,
                    teacher_name:teacher_name,
                    course_url:course_url,
                },function(res){
                    console.log(res);
                    if(res.errCode == 0){
                        // 提示添加成功
                        location.reload()// 刷新当前页面
                    }else{
                        // 提示添加失败
                    }
                })
        })
 })

    
    </script>
</body>

</html>